<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('推送任务')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "special/agency/task";

        $(function() {
            var options = {
                url: prefix + "/list",
                modalName: "推送任务",
                columns: [
                {
                    field: 'id',
                    title: '任务ID',
                },
                {
                    field: 'descInfo',
                    title: '任务描述'
                },
                {
                    field: 'starttime',
                    title: '推送时间',
                    formatter: function (value, row, index){
                        return row.starttime + ' - ' + row.endtime;
                    }
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function (value, row, index) {
                        if (row.status == 0) {
                            return '<span style="color: red">关闭</span>'
                        }else{
                            return '<span style="color: green">打开</span>'
                        }
                        // return statusTools(row);
                    }
                }
                ]
            };
            $.table.init(options);
        });

        /* 用户状态显示 */
        function statusTools(row) {
            if (row.status == 0) {
                return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')"></i> ';
            } else {
                return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')"></i> ';
            }
        }

        /* 用户管理-停用 */
        function disable(id) {
            $.modal.confirm("确认要停用吗？", function() {
                $.operate.post(prefix + "/changeStatus", { "id": id, "status": 0 });
            })
        }

        /* 用户管理启用 */
        function enable(id) {
            $.modal.confirm("确认要启用吗？", function() {
                $.operate.post(prefix + "/changeStatus", { "id": id, "status": 1 });
            })
        }
    </script>
</body>
</html>